<template>
  <div>
    <h1>ElementUI测试</h1>
      <el-breadcrumb separator-class="el-icon-arrow-right">
          <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item>数据报表</el-breadcrumb-item>
          <el-breadcrumb-item>我的报表</el-breadcrumb-item>
      </el-breadcrumb>
      <el-card>
          <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
          <div id="main" style="width: 600px;height:500px;"></div>
      </el-card>

  </div>

</template>


<script>
   //导入
   import echarts from 'echarts'
   //import * as echarts from 'echarts';
    export default {
        data() {
            return {
                loading: false,
                warehouse: [],
            }
        },
        methods: {},
        created() {

        },
        async mounted() {
            const myChart = this.$echarts.init(document.getElementById('main'))
              const option = {
                tooltip: {
                  trigger: 'axis',
                  axisPointer: {
                    type: 'cross'
                  }
                },
                xAxis: [
                  {
                    type: 'category',
                    data: [
                      '1月',
                      '2月',
                      '3月',
                      '4月',
                      '5月',
                      '6月',
                      '7月',
                      '8月',
                      '9月',
                      '10月',
                      '11月',
                      '12月'
                    ],
                    axisPointer: {
                      type: 'shadow'
                    }
                  }
                ],
                yAxis: [
                  {
                    type: 'value',
                    name: '总体积',
                    min: 0,
                    max: 10,
                    interval: 1,
                    axisLabel: {
                      formatter: '{value} m³'
                    }
                  },
                  {
                    type: 'value',
                    name: '使用负荷',
                    min: 0,
                    max: 100,
                    interval: 10,
                    axisLabel: {
                      formatter: '{value} %'
                    }
                  }
                ],
                series: [
                  {
                    name: '总体积',
                    type: 'bar',
                    data: [2.0, 4.9, 5.5, 2.2, 4.6, 6.7, 5.6, 6.2, 3.6, 2.0, 6.4, 3.3],
                    itemStyle: {
                      normal: {
                        color: '#d0e17d'
                      }
                    }
                  },
                  {
                    name: '使用负荷',
                    type: 'line',
                    yAxisIndex: 1,
                    data: [100, 22, 33, 45, 63, 80, 20, 23, 23, 65, 12, 6.2],
                    itemStyle: {
                      normal: {
                        color: '#898989'
                      }
                    }
                  }
                ]
              }

            // 基于准备好的dom，初始化echarts实例
           /* var myChart = echarts.init(document.getElementById('main'));
            // 指定图表的配置项和数据
            var option = {
                title: {
                    text: '仓库使用量'
                },
                tooltip: {},
                legend: {
                    data: ['已使用','容量']
                },
                xAxis: {
                    data: ["衬衫", "羊毛衫", "雪纺衫", "裤子"]
                },
                yAxis: {},
                series: [
                    {
                        name: '已使用',
                        type: 'bar',
                        data: [5, 20, 36, 10]
                    },
                    {
                        name: '容量',
                        type: 'bar',
                        data: [5, 20, 36, 10]
                    },
                ]
            }; */
          /* const res = await this.$http.get('/warehouse/myWarehouse');
            if (res) {
                this.warehouse = res.obj;
                console.log(res.obj)
            }
            for (let i = 0; i < this.warehouse.length; i++) {
                option.xAxis.data[i] = this.warehouse[i].num+this.warehouse[i].name;
                option.series[0].data[i] = this.warehouse[i].used;
                option.series[1].data[i] = this.warehouse[i].capacity;

            }

            // 使用刚指定的配置项和数据显示图表。*/
            myChart.setOption(option);

        }
    }
</script>

<style>
</style>
